<template>
  <a-card :bordered="false">
    <div class="ant-descriptions-title">乐管家钱包</div>
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
          <a-col :md="4" :sm="24">
            <a-form-item>
              <a-input placeholder="请输入姓名" v-model="queryParam.name" />
            </a-form-item>
          </a-col>
          <a-col :md="4" :sm="24">
            <span class="table-page-search-submitButtons">
              <a-button type="primary" @click="handleSearch(true)" icon="search">查询</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
      <s-table
        ref="table"
        size="default"
        rowKey="id"
        :columns="columns"
        :data="loadData"
        :pageSize="5"
        :pagination="pagination">
        <template slot="actions" slot-scope="text, record">
          <a @click="handleDetail(record)">详情</a>
        </template>
      </s-table>
    </div>
  </a-card>
</template>

<script>
import { stewardWalletList } from '@/api/stat'
import formTableMixin from '@/mixins/formTableMixin'

const columns = [
  {
    title: '名称',
    dataIndex: 'name'
  },
  {
    title: '电话',
    dataIndex: 'mobile'
  },
  {
    title: '总金额',
    dataIndex: 'cnt.all_money',
    customRender (text) {
      return '￥' + text
    }
  },
  {
    title: '充值金额',
    dataIndex: 'cnt.topup_money',
    customRender (text) {
      return '￥' + text
    }
  },
  {
    title: '已用金额',
    dataIndex: 'cnt.take_money',
    customRender (text) {
      return '￥' + text
    }
  },
  {
    title: '可用金额',
    dataIndex: 'cnt.usable_money',
    customRender (text) {
      return '￥' + text
    }
  },
  {
    title: '总积分',
    dataIndex: 'cnt.all_integral'
  },
  {
    title: '已用积分',
    dataIndex: 'cnt.take_integral'
  },
  {
    title: '可用积分',
    dataIndex: 'cnt.usable_integral'
  },
  {
    title: '操作',
    dataIndex: 'actions',
    width: '150px',
    scopedSlots: { customRender: 'actions' }
  }
]
export default {
  mixins: [formTableMixin],
  data () {
    this.columns = columns
    this.listAction = parameter => {
      const params = {
        store_id: this.$route.query.id,
        store_type: this.$route.query.type
      }
      return stewardWalletList({ ...parameter, ...params })
    }
    return {}
  },
  methods: {
    handleDetail (record) {
      this.$router.push({
        name: 'stewardWalletDetail',
        query: {
          id: record.id,
          name: record.name
        }
      })
    }
  }
}
</script>
